Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.ComponentModel
Imports System.Drawing.Design
Imports System
Imports System.Web
Imports System.ComponentModel.Design
Imports System.Reflection
Imports System.Web.HttpContext
Imports System.Collections

<Serializable()> _
Public Class ItemCarga

    Private strTexto As String
    Private strValor As String
    Private bolSelecionado As Boolean

    <Category("Dados do Item"), _
    DefaultValue(GetType(String), ""), _
    DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
    Public Property Valor() As String
        Get
            Return strValor
        End Get
        Set(ByVal Value As String)
            strValor = Value
        End Set
    End Property

    <Category("Dados do Item"), _
    DefaultValue(GetType(String), ""), _
    DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
 Public Property Texto() As String
        Get
            Return strTexto
        End Get
        Set(ByVal Value As String)
            strTexto = Value
        End Set
    End Property

    <Category("Dados do Item"), _
DefaultValue(GetType(String), ""), _
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
Public Property Selecionado() As Boolean
        Get
            Return bolSelecionado
        End Get
        Set(ByVal Value As Boolean)
            bolSelecionado = Value
        End Set
    End Property

    Public Sub New(ByVal strTexto As String, ByVal strValor As String, ByVal bolSelecionado As Boolean)
        Me.strTexto = strTexto
        Me.strValor = strValor
        Me.bolSelecionado = bolSelecionado
    End Sub

    Public Sub New()

        Me.strTexto = ""
        Me.strValor = ""
        '        Me.bolSelecionado = False

    End Sub

End Class

<Serializable(), ParseChildren(False)> _
Public Class ColecaoItemCarga
    Inherits System.Collections.CollectionBase

    Public Event ItemAdicionado(ByRef Item As ItemCarga)

    Private strDIVConteudo As String = ""

    Public Property IdDIVConteudo() As String
        Get
            Return strDIVConteudo
        End Get
        Set(ByVal Value As String)
            strDIVConteudo = Value
        End Set
    End Property

    Public Function Item(ByVal i As Long) As ItemCarga

        Return Me.InnerList(i)

    End Function

    Public Sub Add(ByVal Ctrl As ItemCarga)
        List.Add(Ctrl)
        RaiseEvent ItemAdicionado(Ctrl)
    End Sub
End Class

Public Class ColecaoItemCargaEditor
    Inherits CollectionEditor

    Public Sub New(ByVal newType As Type)
        MyBase.new(newType)
    End Sub

    Protected Overrides Function CanSelectMultipleInstances() _
    As Boolean
        Return False
    End Function

    Protected Overrides Function CreateCollectionItemType() As Type
        Return GetType(ItemCarga)
    End Function
End Class
